package com.extra_archive.project.iisu.model 
{
	import iisu.util.GestureModel;

	import com.extra_archive.project.iisu.view.BasicSpace3DView;

	import flash.display.DisplayObjectContainer;
	import flash.events.Event;
	import flash.events.EventDispatcher;
	import flash.events.IOErrorEvent;

	/**
	 * @author vkimone
	 */
	public class BasicModel extends EventDispatcher implements IBasicModel
	{
		private var _gesture : GestureModel;
		
		private var _container : DisplayObjectContainer;
		private var _space3DView : BasicSpace3DView;

		private var _isUpdate : Boolean = false;
		private var _isDebugActive: Boolean = false;

		public function BasicModel($applicationContainer : DisplayObjectContainer)
		{
			applicationContainer = $applicationContainer;
			initialize();
		}

		//--------------------------------------------------------------------------
		//
		//    getter / setter
		//
		//--------------------------------------------------------------------------

		public function get gesture() : GestureModel
		{
			return _gesture;
		}

		public function get applicationContainer() : DisplayObjectContainer
		{
			return _container;
		}

		public function set applicationContainer(mc : DisplayObjectContainer) : void 
		{
			_container = mc;
		}
		
		public function get space3DView() : BasicSpace3DView
		{
			return _space3DView;
		}

		public function set space3DView(space3DView : BasicSpace3DView) : void
		{
			_space3DView = space3DView;
		}
		
		public function get isUpdate() : Boolean
		{
			return _isUpdate;
		}

		public function set isUpdate(isUpdate : Boolean) : void
		{
			_isUpdate = isUpdate;
		}
		
		public function get isDebugViewActive() : Boolean
		{
			return _isDebugActive;
		}
		
		public function set isDebugViewActive(isDebugActive : Boolean) : void
		{
			_isDebugActive = isDebugActive;
		}

		//--------------------------------------------------------------------------
		//
		//    Public Methods
		//
		//--------------------------------------------------------------------------

		public function initialize() : void 
		{
			createGestureModel();
		}
		
		public function onGestureConnect(event : Event) : void
		{
		}
		
		public function onGestureIOError(event : IOErrorEvent) : void
		{
		}
		
		public function onGestureClose(event : Event) : void
		{
		}
		
		//--------------------------------------------------------------------------
		//
		//    Private Methods
		//
		//--------------------------------------------------------------------------

		/**
		 * 모델의 초기화가 끝나면 실행
		 */
		protected function startApplication() : void 
		{
			dispatchEvent(new BasicModelEvent(BasicModelEvent.START_APPLICATION));
		}
		
		protected function createGestureModel() : void
		{
			_gesture = GestureModel.getInstance();
			_gesture.addEventListener(Event.CONNECT, onGestureConnect);
			_gesture.addEventListener(IOErrorEvent.IO_ERROR, onGestureIOError);
			_gesture.addEventListener(Event.CLOSE, onGestureClose);
		}
		
		protected function createConfigManager() : void 
		{
			
		}
		
		protected function createAssetManager() : void 
		{
			
		}
	}
}
